/*
 * BusStationApp.cpp
 *
 *  Created on: Jul 18, 2013
 *      Author: m
 */

#include <iostream>
#include "BusStation.h"
#include "Visitor.h"

#define REQUIRED_ARGC 4
#define ARG_BUS_STATION_NAME 1
#define ARG_BUS_STATION_TYPE 2
#define ARG_ATTACHED_BUS_NAME 3

int main( int argc, char* argv[] )
{

    if ( argc != REQUIRED_ARGC )
    {
        std::cerr << "Cantidad de argumentos invalida." << std::endl;
        std::cerr << "Uso:" << argv[0]
                  << " busName busStationType(in|out) attachedBus"<< std::endl;
        return 1;
    }

    std::string busStationName( argv[ARG_BUS_STATION_NAME] );
    std::string busStationTypeString( argv[ARG_BUS_STATION_TYPE] );
    std::string busName( argv[ARG_ATTACHED_BUS_NAME] );

    application::busStationType busStationType;

    if ( busStationTypeString.compare("in") == 0 )
    {
        busStationType = application::ENTRANCE_BUS_STATION;
    }
    else
    {
        if ( busStationTypeString.compare("out") == 0 )
        {
            busStationType = application::EXIT_BUS_STATION;
        }
        else
        {
            std::cerr << "Argumentos invalidos." << std::endl;
            std::cerr << "Uso:" << argv[0]
                      << " busName busStationType(in|out) attachedBus"<< std::endl;
            return 2;
        }
    }

    std::clog << "Bus Station: " << busStationName << std::endl;
    std::clog << "Station Type: " << busStationTypeString << std::endl;
    std::clog << "Attached Bus: " << busName << std::endl;

    application::BusStation busStation( busStationName, busStationType );

    busStation.attachBus( busName );

    while( true )
    {
        busStation.enqueuePassenger();
    }

}
